﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vCurrentUser
    {

        public int ID { set; get; }

        public string CurrentName { set; get; }

        public UserType UserType { set; get; }

        public byte[] Picture { get; set; }
        /// <summary>
        /// 展示主页
        /// </summary>
        public string Show { set; get; }

        public vCurrentUser() { }

        public vCurrentUser(User model)
        {
            this.ID = model.ID;
            this.CurrentName = model.UserName;
            this.UserType = UserType.User;
            this.Show = "/User/Show/" + model.ID;
            this.Picture = model.Picture;
        }

        public vCurrentUser(UserGroup model)
        {
            this.ID = model.ID;
            this.CurrentName = model.GroupName;
            this.UserType = UserType.UserGroup;
            this.Show = "/UserGroup/Show/" + model.ID;
        }


        public vCurrentUser(Business model)
        {
            this.ID = model.ID;
            this.CurrentName = model.BusinessName;
            this.UserType = UserType.Business;
            this.Show = "/Business/Show/" + model.ID;
        }

        public User ToUser()
        {
            User user = new User();
            DB db = new DB();
            user = db.Users.Find(this.ID);
            return user;
        }

        public UserGroup ToUserGroup()
        {
            UserGroup group = new UserGroup();
            DB db = new DB();
            group = db.UserGroups.Find(this.ID);
            return group;
        }

        public Business ToBusiness()
        {
            Business business = new Business();
            DB db = new DB();
            business = db.Businesses.Find(this.ID);
            return business;
        }


    }
}